{extend name='common@layout/seller' /}
{block name="left"}{include file='common/order_left'}{/block}
{block name="breadcrumb"}
<div class="ncsc-path"><i class="icon-desktop"></i>商家管理中心<i class="icon-angle-right"></i>订单物流<i class="icon-angle-right"></i>发货</div>
{/block}
{block name='content'}
<style type="text/css">
    .sticky .tabmenu { padding: 0;  position: relative; }
</style>
<span class="fr mr5"> <a href="<?php echo url('seller/deliver/waybill_print', array('order_id' => $order_info['order_id']));?>" class="ncsc-btn-mini" target="_blank" title="打印运单"/><i class="icon-print"></i>打印运单</a></span>
<div class="wrap">
    <div class="step-title"><em>第一步</em>确认收货信息及交易详情</div>
    <form name="deliver_form" method="POST" id="deliver_form" action="/?s=seller/deliver/send&order_id={:input('order_id')}" onsubmit="ajaxpost('deliver_form', '', '', 'onerror'); return false;">
        <input type="hidden" value="<?php echo getReferer();?>" name="ref_url">
        <input type="hidden" value="ok" name="form_submit">
        <input type="hidden" id="shipping_express_id" value="<?php echo $order_info['shipping_express_id'];?>" name="shipping_express_id">
        <input type="hidden" value="<?php echo $order_info['extend_order_common']['reciver_name'];?>" name="reciver_name" id="reciver_name">
        <input type="hidden" value="<?php echo $order_info['extend_order_common']['reciver_info']['area'];?>" name="reciver_area" id="reciver_area">
        <input type="hidden" value="<?php echo $order_info['extend_order_common']['reciver_info']['street'];?>" name="reciver_street" id="reciver_street">
        <input type="hidden" value="<?php echo $order_info['extend_order_common']['reciver_info']['mob_phone'];?>" name="reciver_mob_phone" id="reciver_mob_phone">
        <input type="hidden" value="<?php echo $order_info['extend_order_common']['reciver_info']['tel_phone'];?>" name="reciver_tel_phone" id="reciver_tel_phone">
        <input type="hidden" value="<?php echo $order_info['extend_order_common']['reciver_info']['dlyp'];?>" name="reciver_dlyp" id="reciver_dlyp">
        <table class="ncsc-default-table order deliver">
            <tbody>
                <?php if (is_array($order_info) and !empty($order_info)) { ?>
                <tr>
                    <td colspan="20" class="sep-row"></td>
                </tr>
                <tr>
                    <td colspan="20">
                        <a href="/?s=seller/order/print&order_id=<?php echo $order_info['order_id'];?>" target="_blank" class="fr" title="打印发货单"/>
                        <i class="print-order"></i>
                        </a>
                        <span class="fr mr30"></span>
                        <span class="ml10">订单编号：<?php echo $order_info['order_sn']; ?></span>
                        <span class="ml20">
                            下单时间：
                            <em class="goods-time"><?php echo date("Y-m-d H:i:s",$order_info['add_time']); ?></em>
                        </span>
                    </td>
                </tr>
                <?php foreach($order_info['extend_order_goods'] as $k => $goods_info) { ?>
                <tr>
                    <td class="bdl w10"></td>
                    <td class="w50"><div class="pic-thumb"><a href="<?php echo url('index/goods/detail',array('goods_id'=>$goods_info['goods_id']));?>" target="_blank"><img alt="<?php echo $goods_info['goods_name']; ?>" src="<?php echo img_url($goods_info['goods_image'],'60'); ?>" /></a></div></td>
                    <td class="tl"><dl class="goods-name">
                            <dt><a target="_blank" href="<?php echo url('index/goods/detail', array('goods_id'=>$goods_info['goods_id']));?>"><?php echo $goods_info['goods_name']; ?></a></dt>
                            <dd><strong>￥<?php echo $goods_info['goods_price']; ?></strong>&nbsp;x&nbsp;<em><?php echo $goods_info['goods_num'];?></em>件</dd>
                        </dl></td>
                    <?php if ((count($order_info['extend_order_goods']) > 1 && $k ==0) || (count($order_info['extend_order_goods']) == 1)){?>
                    <td class="bdl bdr order-info w500" rowspan="<?php echo count($order_info['extend_order_goods']);?>"><dl>
                            <dt>运费：</dt>
                            <dd>
                                <?php if (!empty($order_info['shipping_fee']) && $order_info['shipping_fee'] != '0.00'){?>
                                <?php echo $order_info['shipping_fee'];?>
                                <?php }else{?>
                                （免运费）
                                <?php }?>
                            </dd>
                        </dl>
                        <dl>
                            <dt>发货备忘：</dt>
                            <dd>
                                <textarea name="deliver_explain" cols="100" rows="2" class="w400 tip-t" title="您可以输入一些发货备忘信息（仅卖家自己可见）"><?php echo $order_info['extend_order_common']['deliver_explain'];?></textarea>
                            </dd>
                        </dl></td>
                    <?php }?>
                </tr>
                <?php }?>
                <tr>
                    <td colspan="20" class="tl bdl bdr" style="padding:8px" id="address"><strong class="fl">收货人信息：</strong><span id="buyer_address_span"><?php echo $order_info['extend_order_common']['reciver_name'];?>&nbsp;<?php echo $order_info['extend_order_common']['reciver_info']['phone'];?>&nbsp;<?php echo $order_info['extend_order_common']['reciver_info']['address'];?></span><?php echo $order_info['extend_order_common']['reciver_info']['dlyp'] ? '[自提服务站]' : '';?>
                        <a href="javascript:void(0)" nc_type="dialog" dialog_title="收货人信息" dialog_id="edit_buyer_address" uri="/?s=seller/deliver/buyer_address_edit&order_id=<?php echo $order_info['order_id'];?>" dialog_width="550" class="ncsc-btn-mini fr"><i class="icon-edit"></i>编辑</a></td>
                </tr>
                <?php } else { ?>
                <tr>
                    <td colspan="20" class="norecord"><i>&nbsp;</i><span>暂无符合条件的数据记录</span></td>
                </tr>
                <?php } ?>
            </tbody>
        </table>
        <div class="step-title mt30"><em>第二步</em>确认发货信息</div>
        <div class="deliver-sell-info"><strong class="fl">我的发货信息：</strong>
            <a href="javascript:void(0);" onclick="ajax_form('modfiy_daddress', '选择发货地址', '/?s=seller/deliver/send_address_select&order_id=<?php echo $order_info['order_id'];?>', 640, 0);" class="ncsc-btn-mini fr"><i class="icon-edit"></i>编辑</a> <span id="seller_address_span">
                <?php if (empty($daddress_info)) {?>
                还未设置发货地址，请进入发货设置 > 地址库中添加
                <?php } else { ?>
                <?php echo $daddress_info['seller_name'];?>&nbsp;<?php echo $daddress_info['telphone'];?>&nbsp;<?php echo $daddress_info['area_info'];?>&nbsp;<?php echo $daddress_info['address'];?>
                <?php } ?>
            </span>
        </div>
        <input type="hidden" name="daddress_id" id="daddress_id" value="<?php echo $daddress_info['address_id'];?>">
        <div class="step-title mt30"><em>第三步</em>选择物流服务</div>
        <div class="alert alert-success">您可以通过"发货设置-><a href="{:url('seller/deliver_set/express')}" target="_parent" >默认物流公司</a>"添加或修改常用货运物流。免运或自提商品可切换下方<span class="red">[无需物流运输服务]</span>选项卡并操作。</div>
        <div class="tabmenu">
            <ul class="tab pngFix">
                <li id="eli1" class="active"><a href="javascript:void(0);" onclick="etab(1)">自行联系物流公司</a></li>
                <?php if (empty($order_info['extend_order_common']['reciver_info']['dlyp'])) {?>
                <li id="eli2" class="normal"><a href="javascript:void(0);" onclick="etab(2)">无需物流运输服务</a></li>
                <?php } ?>
            </ul>
        </div>
        <table class="ncsc-default-table order" id="texpress1">
            <tbody>
                <tr>
                    <td class="bdl w150">公司名称</td>
                    <td class="w250">物流单号</td>
                    <td class="tc">备忘</td>
                    <td class="bdr w90 tc">操作</td>
                </tr>
                <?php if (is_array($my_express_list) && !empty($my_express_list)){?>
                <?php foreach ($my_express_list as $k=>$v){?>
                <?php if (!isset($express_list[$v])) continue;?>
                <tr>
                    <td class="bdl"><?php echo $express_list[$v]['e_name'];?></td>
                    <td class="bdl"><input name="shipping_code" type="text" class="text w200 tip-r" title="正确填写物流单号，确保快递跟踪查询信息正确" maxlength="20" nc_type='eb' nc_value="<?php echo $v;?>" /></td>
                    <td class="bdl gray" nc_value="<?php echo $v;?>"></td>
                    <td class="bdl bdr tc"><a nc_type='eb' nc_value="<?php echo $v;?>" href="javascript:void(0);" class="ncsc-btn">确认</a></td>
                </tr>
                <?php }?>
                <?php }?>
            </tbody>
        </table>
        <table class="ncsc-default-table order" id="texpress2" style="display:none">
            <tbody>
                <tr>
                    <td colspan="2"></td>
                </tr>
                <tr>
                    <td class="bdl tr">如果订单中的商品无需物流运送，您可以直接点击确认</td>
                    <td class="bdr tl w400">&emsp;<a nc_type='eb' nc_value="e1000" href="javascript:void(0);" class="ncsc-btn">确认</a></td>
                </tr>
                <tr>
                    <td colspan="2"></td>
                </tr>
            </tbody>
        </table>
    </form>
</div>
<script type="text/javascript" src="/old/data/resource/js/jquery.poshytip.min.js?{$Think.config.version_source}"></script>
<script charset="utf-8" type="text/javascript" src="/old/data/resource/js/jquery-ui/i18n/zh-CN.js?{$Think.config.version_source}" ></script>
<link rel="stylesheet" type="text/css" href="/old/data/resource/js/jquery-ui/themes/ui-lightness/jquery.ui.css?{$Think.config.version_source}"  />
<script type="text/javascript">
                    function etab(t){
                    if (t == 1){
                    $('#eli1').removeClass('normal').addClass('active');
                    $('#eli2').removeClass('active').addClass('normal');
                    $('#texpress1').css('display', '');
                    $('#texpress2').css('display', 'none');
                    } else{
                    $('#eli1').removeClass('active').addClass('normal');
                    $('#eli2').removeClass('normal').addClass('active');
                    $('#texpress1').css('display', 'none');
                    $('#texpress2').css('display', '');
                    }
                    }
                    $(function(){
                    $('.tip-t').poshytip({
                    className: 'tip-yellowsimple',
                            showOn: 'focus',
                            alignTo: 'target',
                            alignX: 'center',
                            alignY: 'top',
                            offsetX: 0,
                            offsetY: 2,
                            allowTipHover: false
                    });
                    $('.tip-r').poshytip({
                    className: 'tip-yellowsimple',
                            showOn: 'focus',
                            alignTo: 'target',
                            alignX: 'right',
                            alignY: 'center',
                            offsetX: - 50,
                            offsetY: 0,
                            allowTipHover: false
                    });
                    $('a[nc_type="eb"]').on('click', function(){
                    if ($('input[nc_value="' + $(this).attr('nc_value') + '"]').val() == ''){
                    showDialog('请填写物流单号', 'error', '', '', '', '', '', '', '', '', 2); return false;
                    }
                    $('input[nc_type="eb"]').attr('disabled', true);
                    $('input[nc_value="' + $(this).attr('nc_value') + '"]').attr('disabled', false);
                    $('#shipping_express_id').val($(this).attr('nc_value'));
                    $('#deliver_form').submit();
                    });
                    $('#add_time_from').datepicker({dateFormat: 'yy-mm-dd'});
                    $('#add_time_to').datepicker({dateFormat: 'yy-mm-dd'});
                    $('.checkall_s').click(function(){
                    var if_check = $(this).attr('checked');
                    $('.checkitem').each(function(){
                    if (!this.disabled)
                    {
                    $(this).attr('checked', if_check);
                    }
                    });
                    $('.checkall_s').attr('checked', if_check);
                    });
                    <?php if ($order_info['shipping_code'] != ''){?>
                            $('input[nc_value="<?php echo $order_info['extend_order_common']['shipping_express_id'];?>"]').val('<?php echo $order_info['shipping_code'];?>');
                    $('td[nc_value="<?php echo $order_info['extend_order_common']['shipping_express_id'];?>"]').html('<?php echo $order_info['extend_order_common']['deliver_explain'];?>');
                    <?php } ?>
                    
                    $('#my_address_add').click(function(){
                            ajax_form('my_address_add', '添加发货地址', '/?s=seller/deliver/send_address_edit', 550, 0);
                    });
                            });
</script>
{/block}